package com.junqi.gateway.auth;

import cn.dev33.satoken.stp.StpInterface;
import com.junqi.common.entity.RedisKeyManager;
import com.junqi.gateway.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 自定义权限验证接口扩展
 */
@Component
public class StpInterfaceImpl implements StpInterface {

    @Autowired
    RedisUtil redisUtil;

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        // 返回此 loginId 拥有的权限列表
        List<String> list=new ArrayList<>();
        return list;
    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        // 返回此 loginId 拥有的角色列表
        List<String> list=new ArrayList<>();
        list.add(redisUtil.getCacheObject(RedisKeyManager.generateKey(RedisKeyManager.USER_ROLE,String.valueOf(loginId))));
        return list;
    }

}
